#![allow(non_camel_case_types, non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::gdi::ffi;
use crate::guard::*;
use crate::kernel::privs::*;
use crate::prelude::*;
impl GdiObject for HRGN {}
impl gdi_Hrgn for HRGN {}
pub trait gdi_Hrgn: Handle {
#[must_use]
fn CreateRectRgn(bounds: RECT) -> SysResult<DeleteObjectGuard<HRGN>> {
unsafe {
ptr_to_sysresult_handle(
ffi::CreateRectRgn(
bounds.left, bounds.top, bounds.right, bounds.bottom),
).map(|h| DeleteObjectGuard::new(h))
}
}
#[must_use]
fn CreateRectRgnIndirect(rc: RECT) -> SysResult<DeleteObjectGuard<HRGN>> {
unsafe {
ptr_to_sysresult_handle(
ffi::CreateRectRgnIndirect(&rc as *const _ as _),
).map(|h| DeleteObjectGuard::new(h))
}
}
#[must_use]
fn CreateRoundRectRgn(
bounds: RECT,
size: SIZE,
) -> SysResult<DeleteObjectGuard<HRGN>>
{
unsafe {
ptr_to_sysresult_handle(
ffi::CreateRoundRectRgn(
bounds.left, bounds.top, bounds.right, bounds.top,
size.cx, size.cy,
),
).map(|h| DeleteObjectGuard::new(h))
}
}
fn OffsetClipRgn(&self, x: i32, y: i32) -> SysResult<co::REGION> {
match unsafe { ffi::OffsetClipRgn(self.ptr(), x, y) } {
0 => Err(GetLastError()),
ret => Ok(unsafe { co::REGION::from_raw(ret) }),
}
}
fn OffsetRgn(&self, x: i32, y: i32) -> SysResult<co::REGION> {
match unsafe { ffi::OffsetRgn(self.ptr(), x, y) } {
0 => Err(GetLastError()),
ret => Ok(unsafe { co::REGION::from_raw(ret) }),
}
}
#[must_use]
fn PtInRegion(&self, x: i32, y: i32) -> bool {
unsafe { ffi::PtInRegion(self.ptr(), x, y) != 0 }
}
#[must_use]
fn RectInRegion(&self, rc: &RECT) -> bool {
unsafe { ffi::RectInRegion(self.ptr(), rc as *const _ as _) != 0 }
}
}